home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / examples / timing_slave.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  2KB  |  83 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: timing_slave.c,v 1.2 1997/07/09 13:26:19 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33. /*
  34. *    timing_slave.c
  35. *
  36. *    See timing.c
  37. */
  38.  
  39. #include <sys/types.h>
  40. #include <fcntl.h>
  41. #include <stdio.h>
  42. #include "pvm3.h"
  43.  
  44. #define ENCODING  PvmDataRaw
  45.  
  46. main(argc, argv)
  47.     int argc;
  48.     char **argv;
  49. {
  50.     int mytid;   /* my task id */
  51.     int dtid;    /* driver task */
  52.     int bufid;
  53.     int n = 0;
  54.  
  55.     /* enroll in pvm */
  56.  
  57.     mytid = pvm_mytid();
  58.  
  59.     /* tell parent I am ready */
  60.  
  61.     pvm_setopt(PvmRoute, PvmRouteDirect);
  62.     pvm_initsend(ENCODING);
  63.     pvm_send( pvm_parent(), 0 );
  64.  
  65.     /* pack mytid in buffer */
  66.  
  67.     pvm_initsend(ENCODING);
  68.     pvm_pkint(&mytid, 1, 1);
  69.  
  70.     /* our job is just to echo back to the sender when we get a message */
  71.  
  72.     while (1) {
  73.         bufid = pvm_recv(-1, -1);
  74.         pvm_bufinfo(bufid, (int*)0, (int*)0, &dtid);
  75.         pvm_freebuf(pvm_getrbuf());  /* for shared memory refcount hang */
  76.         pvm_send(dtid, 2);
  77. /*
  78.         printf("echo %d\n", ++n);
  79. */
  80.     }
  81. }
  82.  
  83.